<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>人和人律师事务所管理系统v1.0-行政人员信息查询</title>

<style type="text/css" media="all">
    .allow-float {clear:none!important;} /* 允许该元素浮动 */
    .stop-float {clear:both!important;} /* 阻止该元素浮动 */
	.float-left {float:left;padding-left:40px}   /*浮动到左边*/
  </style>

<script type="text/javascript">

Ext.onReady(function(){
	//修改行政人员信息窗口
	var modifyAdminWin;
	//待修改的行政人员信息form对象
	var modifyAdminInfo;
	//设定超时时间
    Ext.Ajax.timeout=120000;

	Ext.BLANK_IMAGE_URL = '/ext/resources/images/default/s.gif';
    Ext.QuickTips.init();
    Ext.form.Field.prototype.msgTarget = 'side';
    //查询框
    var searchAdminWindow = new Ext.form.FormPanel({
			title:'行政人员信息查询',
			labelSeparator :'：',//分隔符
			labelWidth : 100,//标签宽度
			bodyStyle:'padding:5',//表单边距
			frame : true,
			collapsible: true,
			height:100,
			width:window.screen.width-225,
			applyTo :'searchAdminWin',

			items:[
				new Ext.form.TextField({
					fieldLabel:'行政人员姓名',
					id : 'adminPerName',
					name : 'adminPerName',
					width:(window.screen.width-320)*0.20,
					itemCls:'float-left',//向左浮动
					clearCls:'allow-float',//允许浮动
					selectOnFocus : true,//得到焦点时自动选择文本
					allowBlank : true
				}),

				new Ext.Button({
					text : '开始查询',
					iconCls:'search',
					cls:'float-left',//向左浮动
					clearCls:'allow-float',//允许浮动
					handler : submitMsg
				})
			]

		})


	//查询处理函数
	function submitMsg(){
		var adminPerName=Ext.getCmp("adminPerName").getValue();
		//判断用户是否输入了查询条件
		if(adminPerName==""){
			Ext.Msg.alert('提示','请输入查询条件');
			return;
		}
		 store = new Ext.data.JsonStore({
				url:"SearchAdminPersonInfo.jsj?adminPerName="+adminPerName,
				totalProperty: 'totalCount',
			    root: 'result',
				fields:["adminpersonid","adminpersonname","birthtime","adminpersonsex","politicalstatus","educationallevel",
				"graduateschool","adminpersonphone","pracagreement","identitynumber","adminpersonemail","adminpersonposition"]
			});
		store.reload({
			params:{
				start:0,
				limit:5
				}
			});
		var colModel = new Ext.grid.ColumnModel([//配置表格列
				new Ext.grid.RowNumberer({
					header : '行号',
					width : 40
				}),
				cb,
				{header: "行政人员ID", width: 100, dataIndex: 'adminpersonid', sortable: true},
				{header: "行政人员姓名", width: 100, dataIndex: 'adminpersonname', sortable: true},
				{header: "出生年月", width: 100, dataIndex: 'birthtime', sortable: true},
				{header: "性别", width: 75, dataIndex: 'adminpersonsex', sortable: true},
				{header: "政治面貌", width: 100, dataIndex: 'politicalstatus', sortable: true},
				{header: "文化程度", width: 100, dataIndex: 'educationallevel', sortable: true},
				{header: "毕业院校", width: 150, dataIndex: 'graduateschool', sortable: true},
				{header: "联系方式", width: 100, dataIndex: 'adminpersonphone', sortable: true},
				{header: "是否签订聘用合同", width: 150, dataIndex: 'pracagreement', sortable: true},
				{header: "身份证号", width: 150, dataIndex: 'identitynumber', sortable: true},
				{header: "邮箱", width: 150, dataIndex: 'adminpersonemail', sortable: true},
				{header: "职位", width: 100, dataIndex: 'adminpersonposition', sortable: true},
				]);
				pagebar.bind(store);
				grid.reconfigure(store,colModel);
				grid.getView().refresh(true);
	}

    	//存储器
		var store = new Ext.data.JsonStore({
				url:"AdminPersonInfoRequest.jsj",
				totalProperty: 'totalCount',
				root: 'result',
				fields:["adminpersonid","adminpersonname","birthtime","adminpersonsex","politicalstatus","educationallevel",
				"graduateschool","adminpersonphone","pracagreement","identitynumber","adminpersonemail","adminpersonposition"]
			});
		store.load({
			params:{
				start:0,
				limit:5
				}
			});


	//获得用户权限
		var buttonDisabled=true;
	<%
	if((Integer)session.getAttribute("popedomLevel")==1){
		%>
		buttonDisabled=false;
	<%
	}
	%>



	//创建工具栏组件
		var toolbar = new Ext.Toolbar([
			{text : '行政人员基本信息'},
			'-',
			{
			text:'修改选定行政人员信息',
			iconCls:'option',
			disabled:buttonDisabled,
			handler:function(btn,pressed){
			modifyAdminPersInfo();
			}
			},
			'-',
			{
			text:'删除选定行政人员信息',
			iconCls:'remove',
			disabled:buttonDisabled,
			handler:function(btn,pressed){
			deleteAdminPersInfo();
			}
			}
		]);


		//删除律师信息函数
		function deleteAdminPersInfo(){
		var record = grid.getSelectionModel().getSelected();
	        if (!record) {
	           Ext.MessageBox.alert('删除操作','请选择要删除的一项！');
	        } else {
	            deleteAdminWin();
	              Ext.getCmp("adminPersonId").setValue(record.get("adminpersonid"));
		}
		}


		//暂存要被删除的记录ID
		var deleteID=new Ext.form.TextField({
					id : 'adminPersonId',
					name : 'adminPersonId',
				});



		//删除律师信息窗口
		var deleteAdminWin=function(){
				Ext.MessageBox.confirm("删除","确认要删除吗？",deleteDispose)
   		 };

		//删除律师信息处理函数
		function deleteDispose(btn){
		if(btn=='yes'){
		var adminId=Ext.getCmp("adminPersonId").getValue();
		var requestConfig = {
			url :'deleteAdminPersInfo.jsj?adminId='+adminId,//请求的服务器地址
			success:function(response,options){
                        var jsonObj=Ext.util.JSON.decode(response.responseText);
                       Ext.MessageBox.alert("结果",jsonObj.message);
                       //重新加载数据
                       store.load( {
                                params : {
                                    start : 0,
                                    limit : 5
                                }
                            });
                       },
                       failure:function(response,ooptions){
                        var jsonObj=Ext.util.JSON.decode(response.responseText);
                       Ext.MessageBox.alert("结果",jsonObj.message);
                       }
			}
		}
		Ext.Ajax.request(requestConfig);//发送请求

		}

		var protocoldatas=[{id:'0',name:'没有签订协议'},{id:'1',name:'签订了协议'}];

		var protocolstore=new Ext.data.JsonStore({ data:protocoldatas,fields:["id","name"]});

		//修改律师信息函数
		function modifyAdminPersInfo(){
		var record = grid.getSelectionModel().getSelected();
        if (!record) {
           Ext.MessageBox.alert('修改操作','请选择要修改的一项！');
        } else {
            myFormWin();

                Ext.getCmp("adminpersonid").setValue(record.get("adminpersonid"));
            	Ext.getCmp("adminpersonname").setValue(record.get("adminpersonname"));
            	Ext.getCmp("birthtime3").setValue(record.get("birthtime"));
            	Ext.getCmp("adminpersonsex").setValue(record.get("adminpersonsex"));
            	Ext.getCmp("politicalstatus3").setValue(record.get("politicalstatus"));
            	Ext.getCmp("educationallevel3").setValue(record.get("educationallevel"));
            	Ext.getCmp("graduateschool3").setValue(record.get("graduateschool"));
            	Ext.getCmp("adminpersonphone").setValue(record.get("adminpersonphone"));
            	var protocolString=record.get("pracagreement");
            	var protocolNumb;
            	if(protocolString=="签订了协议"){
					protocolNumb=1;
            	}else{
            		protocolNumb=0;
            	}
            	Ext.getCmp("pracagreement2").setValue(protocolNumb);
            	Ext.getCmp("identitynumber3").setValue(record.get("identitynumber"));
            	Ext.getCmp("adminpersonemail").setValue(record.get("adminpersonemail"));
            	Ext.getCmp("adminpersonposition").setValue(record.get("adminpersonposition"));
        }
		}
		//修改律师信息窗口
		var myFormWin = function() {
            modifyAdminWin = new Ext.Window( {
                layout : 'fit',
                width : 800,
                height : 450,
                closeAction : 'hide',
                plain : true,
                title : '修改行政人员信息窗口',
                items : modifyAdminInfo
            });
        modifyAdminWin.show();
    };

    modifyAdminInfo = new Ext.FormPanel( {
         collapsible : true,// 是否可以展开
        labelWidth : 100,
        labelAlign:'rigth',
        buttonAlign:'center',
        frame : true,
        bodyStyle : 'padding:5px 5px 0',
        waitMsgTarget : true,

        defaults : {
            width : 230
        },
        defaultType : 'textfield',


        items : [
        {
            fieldLabel : '行政人员ID',
            itemCls:'float-left',//向左浮动
			clearCls:'allow-float',//允许浮动
            name :'adminpersonid',
            readOnly:true,
             id :'adminpersonid',
            allowBlank :false
        },


        {
            fieldLabel : '行政人员姓名',
            itemCls:'float-left',//向左浮动
			clearCls:'allow-float',//允许浮动
            name :'adminpersonname',
             id :'adminpersonname',
            allowBlank :false
        },
        {
                   fieldLabel :'出生年月',
					id :'birthtime3',
					name :'birthtime3',
					itemCls:'float-left',//向左浮动
					clearCls:'allow-float',//允许浮动
					allowBlank :true
        },

        {
            fieldLabel : '性别',
            itemCls:'float-left',//向左浮动
					clearCls:'allow-float',//允许浮动
            name :'adminpersonsex',
            id:"adminpersonsex",
            allowBlank : false
        },
        {
            fieldLabel : '政治面貌',
            itemCls:'float-left',//向左浮动
					clearCls:'allow-float',//允许浮动
            name :'politicalstatus3',
            id:"politicalstatus3",
            allowBlank : false
        },
        {
            fieldLabel : '文化水平',
            itemCls:'float-left',//向左浮动
					clearCls:'allow-float',//允许浮动
            name :'educationallevel3',
            id:"educationallevel3",
            allowBlank : false
        },

         {
            fieldLabel : '毕业院校',
            itemCls:'float-left',//向左浮动
					clearCls:'allow-float',//允许浮动
            name :'graduateschool3',
            id:"graduateschool3",
            allowBlank : false
        },

        {
            fieldLabel : '联系方式',
            itemCls:'float-left',//向左浮动
					clearCls:'allow-float',//允许浮动
            name :'adminpersonphone',
            id:"adminpersonphone",
            allowBlank : false
        },
         new Ext.form.ComboBox({
			fieldLabel:'聘用合同',
			itemCls:'float-left',//向左浮动
			clearCls:'allow-float',//允许浮动
			store:protocolstore,
			valueField:'id',
			displayField:'name',
			mode:'local',
			forceSelection:true,
			hiddenName:'adpracagreement',
			editable:false,
			triggerAction:'all',
			id:'pracagreement2',
			name:'pracagreement2'
			}),
         {
            fieldLabel : '身份证号',
            itemCls:'float-left',//向左浮动
					clearCls:'allow-float',//允许浮动
            name :'identitynumber3',
            id:"identitynumber3",
            allowBlank : false
        },

         {
            fieldLabel : '邮箱',
            itemCls:'float-left',//向左浮动
					clearCls:'allow-float',//允许浮动
            name :'adminpersonemail',
            id:"adminpersonemail",
            allowBlank : false
        },
         {
            fieldLabel : '职位',
            itemCls:'float-left',//向左浮动
					clearCls:'allow-float',//允许浮动
            name :'adminpersonposition',
            id:"adminpersonposition",
            allowBlank : false
        }
        ],

        buttons : [ {
            text : '保存',
            iconCls:'save',
            disabled : false,
            handler : function() {
                if (modifyAdminInfo.form.isValid()) {
                    modifyAdminInfo.form.submit( {
                        url : 'modifyAdminPersInfo.jsj',
                        success : function(from, action) {
                         Ext.MessageBox.alert('保存成功', '修改律师信息成功！');
                            store.load( {
                                params : {
                                    start : 0,
                                    limit : 5
                                }
                            });
                            modifyAdminWin.hide();
                        },
                        failure : function(form, action) {
                           Ext.MessageBox.alert('保存失败', '修改律师信息失败！');
                        },
                        waitMsg : '正在保存数据，稍后...'
                    });
                   // dialog.hide();
                } else {
                    Ext.Msg.alert('信息', '请填写完成再提交!');
                }
            }
        }, {
            text : '取消',
            iconCls:'cancel',
            handler : function() {
                modifyAdminWin.hide();
            }
        }]
    });


		//分页工具栏
		var pagebar = new Ext.PagingToolbar({
			store : store,
			pageSize : 5,
			displayInfo : true,
			displayMsg : '第 {0} ~ {1} 条 共 {2} 条',
			emptyMsg : '当前没有记录'
		});
		//创建选择模式对象
	var cb = new Ext.grid.CheckboxSelectionModel()
	//创建Grid表格组件
	var grid = new Ext.grid.GridPanel({
			renderTo : 'grid-div3',
			frame : true,
			tbar : toolbar,
			bbar : pagebar,
			trackMouseOver:true, //鼠标特效
			loadMask: true,    //是否显示正在加载
			store : store,
			height : 320,
			width : window.screen.width-220,
			stripeRows : true,
			autoScroll : true,
			viewConfig : {autoFill : false},
			sm : cb,
			columns: [//配置表格列
				new Ext.grid.RowNumberer({
					header : '行号',
					width : 40
				}),
				cb,
				{header: "行政人员ID", width: 100, dataIndex: 'adminpersonid', sortable: true},
				{header: "行政人员姓名", width: 100, dataIndex: 'adminpersonname', sortable: true},
				{header: "出生年月", width: 100, dataIndex: 'birthtime', sortable: true},
				{header: "性别", width: 75, dataIndex: 'adminpersonsex', sortable: true},
				{header: "政治面貌", width: 100, dataIndex: 'politicalstatus', sortable: true},
				{header: "文化程度", width: 100, dataIndex: 'educationallevel', sortable: true},
				{header: "毕业院校", width: 150, dataIndex: 'graduateschool', sortable: true},
				{header: "联系方式", width: 100, dataIndex: 'adminpersonphone', sortable: true},
				{header: "是否签订聘用合同", width: 150, dataIndex: 'pracagreement', sortable: true},
				{header: "身份证号", width: 150, dataIndex: 'identitynumber', sortable: true},
				{header: "邮箱", width: 150, dataIndex: 'adminpersonemail', sortable: true},
				{header: "职位", width: 100, dataIndex: 'adminpersonposition', sortable: true},
				]
		});
});

</script>
</head>
<body>
<table><tr><td>
<div id='searchAdminWin' style="margin:8px 8px 4px 8px"></div>
</td></tr>
</table>
<div id='grid-div3' style="margin:4px 8px 8px 8px"></div>


</body>
</html>